from django.shortcuts import render
from django.http import HttpResponse, request, response
from myapp.models import plan
# Create your views here.
def index(request):
    return render(request,"myapp/x.html")

#登录后的界面
def users(request):
    uinput=request.POST.get("input")
    upassword=request.POST.get("password")
    #if uinput=="lgb" and upassword=="13243546":
    print(uinput,upassword)
    if uinput=="lgb666" and upassword=="lgb666":
        return render(request,"myapp/y.html")
    else:
        return render(request,"myapp/wrong.html")

#主菜单里的返回主界面
def users_2(request):
    return render(request,"myapp/y.html")


def photo(request):
    return render(request,"myapp/photo.html")

def zzy(request):
    return render(request,"myapp/zzy.html")

def book(request):
    return render(request,"myapp/book.html")

def an(request):
    return render(request,"myapp/animation.html")

#表格
def plans(request):
    ob = plan.objects.all()
    context={"infor":ob}
    return render(request,"myapp/plan.html",context)



#--------------表格的修改功能,开始--------------#

def update(request):
    a = request.POST.get("date1")
    if a in ["1","2","3","4","5","6","7","8","9","10","11","12","13"]:
        b=request.POST.get("information")
        a=int(a)
        op1=plan.objects.get(id=a)
        op1.mon=b
        op1.save()
        return render(request,"myapp/right.html")
    else:
        return render(request,"myapp/fault.html")
    
def update2(request):
    a = request.POST.get("date2")
    if a in ["1","2","3","4","5","6","7","8","9","10","11","12","13"]:
        b=request.POST.get("information")
        a=int(a)
        op1=plan.objects.get(id=a)
        op1.tue=b
        op1.save()
        return render(request,"myapp/right.html")
    else:
        return render(request,"myapp/fault.html")

def update3(request):
    a = request.POST.get("date3")
    if a in ["1","2","3","4","5","6","7","8","9","10","11","12","13"]:
        b=request.POST.get("information")
        a=int(a)
        op1=plan.objects.get(id=a)
        op1.wed=b
        op1.save()
        return render(request,"myapp/right.html")
    else:
        return render(request,"myapp/fault.html")
    

def update4(request):
    a = request.POST.get("date4")
    if a in ["1","2","3","4","5","6","7","8","9","10","11","12","13"]:
        b=request.POST.get("information")
        a=int(a)
        op1=plan.objects.get(id=a)
        op1.thu=b
        op1.save()
        return render(request,"myapp/right.html")
    else:
        return render(request,"myapp/fault.html")
    

def update5(request):
    a = request.POST.get("date5")
    if a in ["1","2","3","4","5","6","7","8","9","10","11","12","13"]:
        b=request.POST.get("information")
        a=int(a)
        op1=plan.objects.get(id=a)
        op1.fri=b
        op1.save()
        return render(request,"myapp/right.html")
    else:
        return render(request,"myapp/fault.html")

def update6(request):
    a = request.POST.get("date6")
    if a in ["1","2","3","4","5","6","7","8","9","10","11","12","13"]:
        b=request.POST.get("information")
        a=int(a)
        op1=plan.objects.get(id=a)
        op1.sat=b
        op1.save()
        return render(request,"myapp/right.html")
    else:
        return render(request,"myapp/fault.html")

def update7(request):
    a = request.POST.get("date7")
    if a in ["1","2","3","4","5","6","7","8","9","10","11","12","13"]:
        b=request.POST.get("information")
        a=int(a)
        op1=plan.objects.get(id=a)
        op1.sun=b
        op1.save()
        return render(request,"myapp/right.html")
    else:
        return render(request,"myapp/fault.html")
#--------------表格的修改功能,结束--------------#